<html><body><pre>Hello CMake
<h3>
Introduction
-------------
</h3>
A short tutorial on using cmake and the android ndk standalone toolchain.
<h3>
I. Requirements
----------------
</h3>
You will need ant to compile the java.
  sudo apt-get install ant

You must have the android standalone toolchain either in /opt/android-toolchain
or have the environment variable set:
  export ANDROID_NDK_TOOLCHAIN_ROOT=$HOME/android-toolchain

Also, please set the android.toolchain.cmake as an evironment variable for the
convience of this tutorial.
  export ANDTOOLCHAIN=~/android-cmake/toolchain/android.toolchain.cmake
  
Highly recommended that you either use cmake-gui or ccmake to step through the
cmake process. 
<h3>
II. Build for the PC
-------------------
</h3>
cd to the samples/hello-cmake directory
  mkdir pcbuild
  cd pcbuild
  cmake ..
  make

Now build the java. cd to samples/hello-cmake
  ./build_java.sh
  ./run_java.sh
  Hello from JNI !

If you look in run_java.sh, it exports the lib/pc path (where the shared library
was put), so that the java may load the shared library.
<h3>
III.  Build for the Android
-------------------
</h3>
cd to the samples/hello-cmake directory
  export ANDROID_NDK_TOOLCHAIN_ROOT=~/android-toolchain
  export ANDTOOLCHAIN=~/android-cmake/toolchain/android.toolchain.cmake
  mkdir androidbuild
  cd androidbuild
  cmake -DCMAKE_TOOLCHAIN_FILE=$ANDTOOLCHAIN ..
  make

You should see something like:
  Linking C shared library ../libs/armeabi-v7a/libhello-cmake.so

Try cmake-gui and play with the arm targets and such.

Please look at the cmake lists, it simple and commented.

<h3>
IV. Install for Android
-------------------
</h3>
Lets get this shared library ready for android.

  cd androidbuild
  cmake-gui ..

Now in select armeabi for ARM_TARGETS.  This is created by the android.toolchain
and determines the abi compatibility of the shared library.  It will also change
the install directory of the shared library.

Also, point the LIBRARY_OUTPUT_PATH_ROOT to samples/hello-android-cmake path.
This has the effect of installing the shared library into the correct folder
for android sdk build system.

  make

Now rerun cmake-gui and select armeabi-v7a for the ARM_TARGETS. Run make,
and you should now see the two versions of the shared library installed in
the hello-android-cmake/libs directory.

You may want to set the advanced CMAKE_VERBOSE_MAKEFILE flag from cmake-gui, to
see the compiler and linker flags.
 
Now you are ready to move on to the <a href="hello-android-cmake.html">hello-android-cmake.html</a> sample.
</pre></body></html>
